﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace tiDE.AddIns
{
    public class AddInProvider
    {
        List<IAddIn> RunningAddIns = new List<IAddIn>();

        public void LoadAddIn(string AddInPath)
        {
            Assembly assembly = Assembly.LoadFile(AddInPath);
            Type[] types = assembly.GetTypes();
            foreach (Type type in types)
            {
                if (type.GetInterface("IAddIn") != null)
                {
                    // Load this add in
                    RunningAddIns.Add((IAddIn)Activator.CreateInstance(type));
                    RunningAddIns.Last().FirstRun();
                    RunningAddIns.Last().Initialize();
                }
            }
        }
    }
}
